package day14.tarena.com;

import java.util.Comparator;
import java.util.TreeSet;

public class StudentGen implements Comparable<StudentGen> {
		private int id;
		private String name;
		
		public StudentGen(int id, String name) {
			super();
			this.setId(id);
			this.setName(name);
		}	
		
		public int compareTo(StudentGen sg){  //用泛型规范参数类型；
			if(sg == null) return 0;
			return sg.id - this.id;
		
		}
		public StudentGen() {
			super();
			
			
		}
		public int getId() {
			return id;
		}
		public void setId(int id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		
		public static void main(String args[]){
			StudentGen sg1 = new StudentGen(23, "Wangpeihu");
			StudentGen sg2 = new StudentGen(32, "hupeiwang");
			
				TreeSet ts = new TreeSet(new Comparator<StudentGen>(){
					public int compare(StudentGen sg1, StudentGen sg2){
						if(sg1 == null || sg2 == null)return 0;
						return sg1.id - sg2.id;
					}
				});
				System.out.println();
		}
}
